#!usr/bin/env python3
# -*- coding:utf-8 -*-

#读取配置文件的类

import day6_config_default

class Dict(dict):
	"""docstring for Dict"""
	def __init__(self, names=(),values=(),**kw):
		super(Dict, self).__init__(**kw)
		for k,v in zip(names,values):
			self[k] = v;
	def __getattr__(self,key):
		try:
			return self[key]
		except KeyError:
			raise AttributeError(r"'Dict' object has no attrbute '%s' " % key)

	def __setattr__(self,key,value):
		self[key] = value

#合并两个dict
def merge(defaults,override):
	r = {}
	for k,v in defaults.items():
		if k in override:
			if isinstance(v,dict):
				r[k] = merge(defaults[k],override[k])
			else:
				r[k] = override[k]
		else:
			r[k] = v;
	return r

def toDict(d):
	ret = Dict();
	for k,v in d.items():
		ret[k] = toDict(v) if isinstance(v,dict) else v;
	return ret

configs = day6_config_default.configs;

try:
	import day6_config_override
	configs = merge(configs,day6_config_override.configs)
except ImportError:
	pass

configs = toDict(configs)



	
